<template lang="pug">
    div
        h1 微信失信库列表
        Form(ref="select", inline)
            FormItem(prop="")
                Input(v-model="wx", style="width: 300px", placeholder="输入微信号（支持模糊查询）")
            FormItem
                Button(@click="index") 查找
                Button(@click="wx = '', index()", style="margin-left: 20px") 清空
        el-table(:data="data.data")
            el-table-column(prop="wx",          label="微信号")
            el-table-column(prop="count",       label="失信次数")
            el-table-column(prop="create_time", label="第一次失信时间")
            el-table-column(label="操作")
                template(slot-scope="scope")
                    Button.button(type="info",  @click="destroy(scope.row.id)") 删除
        Page(:total="data.total_count", @on-change="index")

</template>

<script>
    export default {
        data() {
            return {
                page: 1,
                data: {
                    data: [],
                    total_count: 0,
                },
                wx: '',
            }
        },

        methods: {
            async index(page = 1) {
                this.data = await this.$http.post('tools_dishonesty_wx/getList', {page_index: page - 1, page_size: 20, wx: this.wx});
                this.page = page;
            },

            async destroy(id) {
                try {
                    await this.$confirm(`确认删除该失信？`, '失信处理确认');
                    await this.$http.post('tools_dishonesty_wx/del', {id});
                    this.index();
                } catch (e) {}
            }
        },

        created() {
            this.index();
        }
    }
</script>
